#ifndef GTCELL_H
#define GTCELL_H

#include <QQuickPaintedItem>
#include <QPen>
#include <QPainter>
#include <QBrush>
#include <QDebug>

class GtCell : public QQuickPaintedItem
{
    Q_OBJECT
    Q_PROPERTY(quint32 electric READ getElectric WRITE setElectric NOTIFY electricChanged)
    Q_PROPERTY(QColor color READ getColor WRITE setColor NOTIFY colorChanged)
    Q_PROPERTY(quint32 threshold READ getThreshold WRITE setThreshold NOTIFY thresholdChanged)

public:
    using QQuickPaintedItem::QQuickPaintedItem;

    //重写这个绘制方法
    void paint(QPainter*) override;

    //电量
    void setElectric(quint32 value) noexcept;
    //颜色
    void setColor(QColor color) noexcept;
    //警告阈值
    void setThreshold(quint32 value) noexcept;
    quint32 getElectric() const noexcept;
    QColor getColor() const noexcept;
    quint32 getThreshold() const noexcept;

signals:
    void electricChanged();
    void colorChanged();
    void thresholdChanged();

private:
    quint32 m_lineWidth = 1;
    quint32 m_electric = 70;
    QColor m_color = Qt::green;
    QColor m_waringColor = Qt::red;
    quint32 m_threshold = 20;
};

#endif // GTCELL_H
